package com.woniuxy.microfundservice.controller;

import com.alibaba.fastjson.JSONObject;
import com.woniuxy.bean.ResultBean;
import com.woniuxy.microfundservice.bean.info.FundManagers;
import com.woniuxy.microfundservice.service.FundManagersService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * (FundManagers)表控制层
 *
 * @author makejava
 * @since 2021-04-08 09:36:03
 */
@RefreshScope
@Api("基金历史基金经理")
@RestController
@RequestMapping(value = "/fundManagers",produces = MediaType.APPLICATION_JSON_VALUE)
public class FundManagersController {
    /**
     * 服务对象
     */
    @Resource
    private FundManagersService fundManagersService;

    /**
     * 通过主键查询单条数据
     *
     * @param fundId 主键
     * @return 单条数据
     */
    @ApiOperation(("查找基金历史基金经理"))
    @GetMapping("/selectOne")
    public ResultBean selectOne(Integer fundId) {

        List<FundManagers> fundManagers=fundManagersService.selectOne(fundId);
        return ResultBean.builder().code(200).data(fundManagers).build();
    }

    @ApiOperation(("新增基金历史基金经理"))
    @PostMapping("/addOne")
    public ResultBean addOne(@RequestBody List<FundManagers> fundManagers) {

        int res=fundManagersService.addOne(fundManagers);
        return ResultBean.builder().code(200).msg("新增成功").build();
    }

    @ApiOperation(("修改基金历史基金经理"))
    @PutMapping("/updateOne")
    public ResultBean updateOne(@RequestBody FundManagers fundManagers) {

        int res=fundManagersService.updateOne(fundManagers);
        return ResultBean.builder().code(200).msg("修改成功").build();
    }
}